#Boa:Dialog:EditarSenha

import wx

def create(parent, senha):
    return EditarSenha(parent, senha)

[wxID_EDITARSENHA, wxID_EDITARSENHABUTTON1, wxID_EDITARSENHABUTTON2, 
 wxID_EDITARSENHASTATICLINE1, wxID_EDITARSENHASTATICTEXT1, 
 wxID_EDITARSENHASTATICTEXT2, wxID_EDITARSENHASTATICTEXT3, 
 wxID_EDITARSENHATEXTCTRL1, wxID_EDITARSENHATEXTCTRL2, 
 wxID_EDITARSENHATEXTCTRL3, wxID_EDITARSENHAWINDOW1, wxID_EDITARSENHAWINDOW2, 
] = [wx.NewId() for _init_ctrls in range(12)]

class EditarSenha(wx.Dialog):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Dialog.__init__(self, id=wxID_EDITARSENHA, name=u'EditarSenha',
              parent=prnt, pos=wx.Point(674, 256), size=wx.Size(388, 342),
              style=wx.DEFAULT_DIALOG_STYLE, title=u'Edi\xe7\xe3o de Senha')
        self.SetClientSize(wx.Size(380, 309))
        self.Center(wx.BOTH)

        self.window1 = wx.Window(id=wxID_EDITARSENHAWINDOW1, name='window1',
              parent=self, pos=wx.Point(-38, 16), size=wx.Size(456, 176),
              style=0)
        self.window1.Center(wx.HORIZONTAL)

        self.textCtrl1 = wx.TextCtrl(id=wxID_EDITARSENHATEXTCTRL1,
              name='textCtrl1', parent=self.window1, pos=wx.Point(264, 24),
              size=wx.Size(100, 21), style=wx.TE_PASSWORD, value=u'')

        self.staticText1 = wx.StaticText(id=wxID_EDITARSENHASTATICTEXT1,
              label=u'Digite sua senha atual', name='staticText1',
              parent=self.window1, pos=wx.Point(72, 24), size=wx.Size(143, 18),
              style=0)
        self.staticText1.SetFont(wx.Font(11, wx.SWISS, wx.NORMAL, wx.NORMAL,
              False, u'Tahoma'))

        self.staticText2 = wx.StaticText(id=wxID_EDITARSENHASTATICTEXT2,
              label=u'Digite sua nova senha', name='staticText2',
              parent=self.window1, pos=wx.Point(72, 96), size=wx.Size(144, 18),
              style=0)
        self.staticText2.SetFont(wx.Font(11, wx.SWISS, wx.NORMAL, wx.NORMAL,
              False, u'Tahoma'))

        self.staticText3 = wx.StaticText(id=wxID_EDITARSENHASTATICTEXT3,
              label=u'Confirme sua nova senha', name='staticText3',
              parent=self.window1, pos=wx.Point(56, 136), size=wx.Size(167, 18),
              style=0)
        self.staticText3.SetFont(wx.Font(11, wx.SWISS, wx.NORMAL, wx.NORMAL,
              False, u'Tahoma'))

        self.textCtrl2 = wx.TextCtrl(id=wxID_EDITARSENHATEXTCTRL2,
              name='textCtrl2', parent=self.window1, pos=wx.Point(264, 96),
              size=wx.Size(100, 21), style=wx.TE_PASSWORD, value=u'')

        self.textCtrl3 = wx.TextCtrl(id=wxID_EDITARSENHATEXTCTRL3,
              name='textCtrl3', parent=self.window1, pos=wx.Point(264, 136),
              size=wx.Size(100, 21), style=wx.TE_PASSWORD, value=u'')

        self.staticLine1 = wx.StaticLine(id=wxID_EDITARSENHASTATICLINE1,
              name='staticLine1', parent=self.window1, pos=wx.Point(73, 72),
              size=wx.Size(303, 2), style=0)

        self.window2 = wx.Window(id=wxID_EDITARSENHAWINDOW2, name='window2',
              parent=self, pos=wx.Point(-50, 184), size=wx.Size(480, 92),
              style=wx.TAB_TRAVERSAL)
        self.window2.Center(wx.HORIZONTAL)

        self.button1 = wx.Button(id=wxID_EDITARSENHABUTTON1, label=u'Salvar',
              name='button1', parent=self.window2, pos=wx.Point(104, 24),
              size=wx.Size(104, 40), style=0)
        self.button1.SetFont(wx.Font(11, wx.SWISS, wx.NORMAL, wx.NORMAL, False,
              u'Tahoma'))
        self.button1.Bind(wx.EVT_BUTTON, self.OnButton1Button,
              id=wxID_EDITARSENHABUTTON1)

        self.button2 = wx.Button(id=wxID_EDITARSENHABUTTON2, label=u'Cancelar',
              name='button2', parent=self.window2, pos=wx.Point(264, 24),
              size=wx.Size(104, 40), style=0)
        self.button2.SetFont(wx.Font(11, wx.SWISS, wx.NORMAL, wx.NORMAL, False,
              u'Tahoma'))
        self.button2.Bind(wx.EVT_BUTTON, self.OnButton2Button,
              id=wxID_EDITARSENHABUTTON2)

    def __init__(self, parent, senha):
        self._init_ctrls(parent)
        self.SenhaAntiga = senha
        self.NovaSenha = ''

    #Botao "Salvar"
    def OnButton1Button(self, event):
        
        #Verificar senha antiga
        SenhaDigitada = self.textCtrl1.GetValue()
        SenhaNovaDigitada = self.textCtrl2.GetValue()
        SenhaNovaDigitada2 = self.textCtrl3.GetValue()
        if SenhaDigitada != self.SenhaAntiga:
            m = "senha atual incorreta !"
            t = "Alteracao de senha"
            wx.MessageBox(m,t,wx.ICON_EXCLAMATION)
            self.textCtrl1.SetValue('')
            self.textCtrl2.SetValue('')
            self.textCtrl3.SetValue('')
            self.textCtrl1.SetFocus()
            
        
            

            
        #Comparar "senha" e "confirmacao de senha"
        elif SenhaNovaDigitada <> SenhaNovaDigitada2:
            m = "A nova senha que voce digitou nao confere,\nFavor digitar novamente a senha nos dois campos!"
            t = "Alteracao de senha"
            wx.MessageBox(m,t,wx.ICON_EXCLAMATION)
            self.textCtrl2.SetValue('')
            self.textCtrl3.SetValue('')
            self.textCtrl2.SetFocus()
            
        
        #Atribuir Nova Senha ao self.NovaSenha
        else:
            self.NovaSenha = SenhaNovaDigitada
            
            self.Close()
        

    #Botao "Cancelar"
    def OnButton2Button(self, event):
        self.Close()
